import 'dart:convert' show json;

import 'package:x3_base_core/x3_base_core.dart';

class AdvancedFilterModel {
  AdvancedFilterModel({
    this.tagId,
    this.tagName,
    this.tagRemark,
    this.tagDateAging,
    this.tagType,
    this.inputApi,
    this.tagSystemType,
    this.tagAppShow,
    this.tags,
    this.tagIsExpanded,
  });

  factory AdvancedFilterModel.fromJson(Map<String, dynamic> jsonRes) {
    if (jsonRes == null) {
      return null;
    }

    final List<BaseKeyValueModel> tags = jsonRes['tags'] is List ? <BaseKeyValueModel>[] : null;
    if (tags != null) {
      for (final dynamic item in jsonRes['tags']) {
        if (item != null) {
          tags.add(BaseKeyValueModel.fromJson(asT<Map<String, dynamic>>(item)));
        }
      }
    }
    return AdvancedFilterModel(
      tagId: asT<String>(jsonRes['tagId']),
      tagName: asT<String>(jsonRes['tagName']),
      tagRemark: asT<String>(jsonRes['tagRemark']),
      tagDateAging: asT<String>(jsonRes['tagDateAging']),
      tagType: asT<String>(jsonRes['tagType']),
      inputApi: asT<String>(jsonRes['inputApi']),
      tagSystemType: asT<int>(jsonRes['tagSystemType']),
      tagAppShow: asT<bool>(jsonRes['tagAppShow']),
      tagIsExpanded: asT<bool>(jsonRes['tagIsExpanded']),
      tags: tags,
    );
  }

  String tagId;
  String tagName;
  String tagRemark;
  String tagDateAging;
  String tagType;
  String inputApi;
  int tagSystemType;
  bool tagAppShow;
  List<BaseKeyValueModel> tags;
  bool tagIsExpanded;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'tagId': tagId,
        'tagName': tagName,
        'tagRemark': tagRemark,
        'tagDateAging': tagDateAging,
        'tagType': tagType,
        'inputApi': inputApi,
        'tagSystemType': tagSystemType,
        'tagAppShow': tagAppShow,
        'tags': tags,
        'tagIsExpanded': tagIsExpanded,
      };
  @override
  String toString() {
    return json.encode(this);
  }
}
